import os
import sys
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.common.action_chains import ActionChains
class LikeShopTest():
    def __init__(self) -> None:

        driver_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(sys.executable)))),
                               'geckodriver.exe')
        service = FirefoxService(executable_path=driver_path)
        options = webdriver.FirefoxOptions()
        self.browser = webdriver.Firefox(service=service, options=options)

    def test_1(self):
        self.browser.get('http://likeshop.abc:81/admin/account/login.html')
        sleep(2)
        # 定位用户名输入框并输入用户名
        self.browser.find_element(By.NAME,'account').send_keys('admin')
        # 定位密码输入框并输入密码
        self.browser.find_element(By.NAME,'password').send_keys('123456')
        # 定位密码输入框并输入密码
        self.browser.find_element(By.NAME,'code').send_keys('1111')
        # 点击登录
        self.browser.find_element(By.ID,'login').click
        
        sleep(3)
        
if __name__ == '__main__':
   likeShopTest = LikeShopTest()
   likeShopTest.test_1()